<template>
  <!-- 背景图 -->
  <div class="bcg">
    <img src="../img/2a16932008b58e0529dbcf04e511814.png" alt="">
  </div>
  <!-- 登录框 -->
  <div class="register">
    <div>
      <div class="tou"><img src="../img/bd4b7392c3fdc762f3a68ec0039f91c.jpg" alt=""></div>
    </div>
    <div><label for="">账号：</label> <el-input v-model="username" type="text" placeholder="输入你的账号" /></div>
    <div><label for="">密码：</label> <el-input v-model="password" type="password" placeholder="输入你的密码" show-password />
    </div>
    <el-button :plain="true" @click="open2">点击登录</el-button>
  </div>
</template>

<script lang="ts">
import { ElMessage } from 'element-plus'
import { ref } from 'vue'
import router from '../router/index'
export default {
  setup() {
    // 输入框
    let username = ref(null)
    let password = ref(null)
    // 登陆的账号和密码
    let id = ref('123456')
    let code = ref('123456')
    // 登录按钮
    let open2 = () => {
      // ElMessage({
      //   message: '恭喜你登录成功！！！',
      //   type: 'success',
      // })
      // router.push({ name: 'about' })
      if (username.value == id.value && password.value == code.value) {
        localStorage.setItem("username", username.value);
        router.push({ name: "home" });
        ElMessage({
          message: "恭喜你，登录成功",
          type: "success",
        });
      } else {
        password.value = null,
          username.value = null,
          ElMessage({
            message: "请正确输入账号和密码",
            type: "warning",
          });
      }
    }
    return {
      password,
      username,
      open2
    }
  }
}
</script>

<style lang="less">
img {
  width: 100%;
  height: 100%;
}

html,
body {
  height: 100%;
}

// 背景
.bcg {
  position: absolute;
  height: 100%;
}

// 登录盒子
.register {
  position: absolute;
  width: 400px;
  height: 300px;
  background-color: rgba(250, 250, 250, 0.441);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* box-shadow: -10px -10px 5px #ffffffab; */
  box-shadow: 12px 8px 4px 2px rgba(200, 204, 204, 0.744);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;

  // 账号密码框
  .el-input {
    width: 280px;
    height: 50px;
  }

  // 头像
  .tou {
    width: 80px;
    height: 80px;
    text-align: center;
    border-radius: 50%;
    overflow: hidden;
  }

}
</style>
